package com.bienvenue.main.base;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.afollestad.materialdialogs.MaterialDialog;
import com.bienvenue.main.ui.activity.enterprise.PostJobActivity;
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.trello.rxlifecycle2.components.support.RxFragmentActivity;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * @ProjectName: Bienvenue
 * @Package: com.bienvenue.main.base
 * @ClassName: BaseActivity
 * @Description: java类作用描述
 * @Author: Mr.Chen
 * @CreateDate: 2020/9/7 10:46
 * @UpdateUser: Mr.Chen
 * @UpdateDate: 2020/9/7 10:46
 * @UpdateRemark: Activity的Base基类，用于写一些比较基础的功能实现，比如showToast
 * @Version: 1.0
 */


public abstract class BaseActivity extends RxFragmentActivity {
    Unbinder unbinder;

    int position;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        unbinder = ButterKnife.bind(this);
        initView();
        initData();
    }

    //初始化数据的方法
    protected abstract void initData();

    //初始化控件的方法
    protected abstract void initView();

    //填充布局的方法
    protected abstract int getLayoutId();

    public void showToast(String content) {
        Toast.makeText(this, content, Toast.LENGTH_SHORT).show();
    }

    public void showLog(String log) {
        Log.e("TAG", log);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unbinder.unbind();
    }

    public MaterialDialog initDialog(String content) {
        MaterialDialog dialog = new MaterialDialog.Builder(this)
                .content(content)
                .progress(true, 100)
                .cancelable(false)
                .build();
        return dialog;
    }



    protected String getTime(Date date) {//可根据需要自行截取数据显示
        Log.d("getTime()", "choice date millis: " + date.getTime());
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        return format.format(date);
    }
}
